using System;
using System.Collections.Generic;
using UnityEngine;

public class PlayerDB : ScriptableObject
{
	public enum PlayerId
	{
		Player1 = 0,
		Player2 = 1
	}

	[Serializable]
	public class AiPlayerDefinition
	{
		public int index;
	}

	[Serializable]
	public class AiLookDefinition
	{
		public string lookName;

		public AILooksDB.AIPlayerLook look
		{
			get
			{
				AILooksDB.AIPlayerLook aIPlayerLook = AILooksDB.instance.GetAiLook(lookName);
				if (aIPlayerLook == null)
				{
					aIPlayerLook = AILooksDB.instance.looks[0];
				}
				return aIPlayerLook;
			}
		}
	}

	[Serializable]
	public class TournamentPlayer : SkillProvider
	{
		public string playerName;

		public GameConstants.Flags flag;

		public AiLookDefinition lookName;

		public AiPlayerDefinition aiPlalyerDefinition;

		public float forehand;

		public float backspin;

		public float serve;

		public int playerIndex;

		public string shoeId = "shoe1";

		public string racketId = "paddle1";

		public float speedMult = 1f;

		public float enduranceMult = 1f;

		public override float DoGetSkillValue(int skillTypeIndex)
		{
			switch (skillTypeIndex)
			{
			case 0:
				return forehand;
			case 1:
				return backspin;
			case 2:
				return StoreItemsConfig.instance.FindItemWithId(racketId).NormalizedVisualSpeed();
			case 3:
				return StoreItemsConfig.instance.FindItemWithId(shoeId).NormalizedVisualSpeed();
			default:
				return 0f;
			}
		}

		public float GetSkillProgress(int skillTypeIndex)
		{
			return 0f;
		}
	}

	private static PlayerDB instance_;

	public List<TournamentPlayer> players = new List<TournamentPlayer>();

	public static PlayerDB instance
	{
		get
		{
			if (instance_ == null)
			{
				instance_ = Resources.Load("TournamentsDefinitions/PlayerDB", typeof(PlayerDB)) as PlayerDB;
				instance_.Init();
			}
			return instance_;
		}
	}

	public void Init()
	{
		int num = 0;
		foreach (TournamentPlayer player in players)
		{
			player.playerIndex = num;
			num++;
		}
	}

	public TournamentPlayer GetPlayer(int playerIndex)
	{
		return players[Mathf.Clamp(playerIndex, 0, players.Count - 1)];
	}
}
